# -*- coding:utf-8 -*-
#! python3
from facecat import *

#消息循环
def WndProcPopup(hwnd,msg,wParam,lParam):
	global popupPaint
	if (hwnd in popupPaint) == True:
		return WndProcDefault(popupPaint[hwnd],hwnd,msg,wParam,lParam)

popupPaint = dict()

def popupWindow():
	global popupPaint
	pPaint = FCPaint() #创建绘图对象
	wSize = FCSize(500, 500)
	setWindowSize(wSize)
	setCenterScreen(True)
	#初始化窗体
	createWindow(pPaint, "facecat-py2", WndProcPopup)
	popupPaint[pPaint.hWnd] = pPaint
	current_file_path = os.path.abspath(__file__)
	current_file_dir = os.path.dirname(current_file_path)
	file0 = open(current_file_dir + "\\xml\\divexample.xml", encoding="UTF-8")
	xml = file0.read()
	file0.close()
	renderFaceCat(pPaint, xml)
	tabPage = findViewByName("TabPage2", pPaint.views)
	div = FCDiv()
	div.location = FCPoint(50, 50)
	div.size = FCSize(200, 200)
	div.showHScrollBar = True
	div.showVScrollBar = True
	addViewToParent(div, tabPage)
	for i in range(0, 10):
		button = FCButton()
		button.location = FCPoint(i * 40, i * 40)
		button.size = FCSize(100, 20)
		addViewToParent(button, div)
		button.text = "确定"
	showWindow(pPaint)